<%@ page language="java" import="java.util.*" pageEncoding="utf-8" %>
<%@ include file="../../../attr.jsp" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!doctype html>
<html>
<head>
    <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7"/>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta charset="utf-8">
    <link rel="stylesheet" href="${ctx}/css/sapar.css"/>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/common.css"/>
    <script type="text/javascript" src="${ctx}/js/jquery.js"></script>
    <script type="text/javascript" src="${ctx}/js/sapar.js"></script>
    <script type="text/javascript" src="${ctx}/js/WdatePicker.js"></script>
    <script type="text/javascript" src="${ctx}/assets/layer/layer.js"></script>
    <script type="text/javascript" src="${ctx}/js/kkpager.min.js"></script>
    <script type="text/javascript" src="${ctx}/js/mask.js"></script>
    <link rel="stylesheet" type="text/css" href="${ctx}/css/kkpager_blue.css"/>
    <title>新增一个包</title>
    <style type="text/css">
        .kv-item label {
            width: 90px;
        }


    </style>

</head>
<body>
<div id="mask" class="mask"></div>
<div id="saper-container">
    <div id="saper-hd"></div>
    <div id="saper-bd">
        <div class="subfiled clearfix">
            <h2>修改包</h2>
        </div>
        <form class="saper-form" id="dataForm">
            <div class="subfiled-content">
                <div class="tab-container" data-trigger="click">
                    <div class="tab-content">
                        <div class="tab-content-item">
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>包名：</label>
                                <div class="kv-item-content">
                                    <input type="text" placeholder="包名" id="baoming" name="packageName"
                                           value="${muban.packageName}"
                                           onkeyup="this.value=this.value.replace(/(^\s*)|(\s*$)/g,'')">
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo"></span>包大小：</label>
                                <div class="kv-item-content">
                                    <input type="text" placeholder="包大小" name="packageSize" value="${muban.packageSize}"
                                           >
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo"></span>价格：</label>
                                <div class="kv-item-content">
                                    <input type="text" placeholder="价格" name="packagePrice"
                                           value="${muban.packagePrice}" >
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo"></span>功能：</label>
                                <div class="kv-item-content">
                                    <input type="text" placeholder="功能" name="packageFunction"
                                           value="${muban.packageFunction}">
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>所属部门：</label>
                                <div class="kv-item-content">
                                    <%--<c:if test="${muban.packageDepartid ==17 }">--%>
                                    <%--<input type="text" readonly="readonly" value="厂家包">--%>
                                    <%--<input type="hidden" name="packageDepartid" id="packageDepartid" value="${muban.packageDepartid }">--%>
                                    <%--</c:if>--%>
                                    <%--<c:if test="${muban.packageDepartid ==16 }">--%>
                                    <%--<input type="text" readonly="readonly" value="--">--%>
                                    <%--<input type="hidden" name="packageDepartid" id="packageDepartid" value="${muban.packageDepartid }">--%>
                                    <%--</c:if>--%>
                                    <%--<c:if test="${muban.packageDepartid !=16 && muban.packageDepartid != 17 }">--%>
                                    <%--<c:forEach items="${depList}" var="dep">--%>
                                    <%--<c:if test="${muban.packageDepartid == dep.departmentId }">--%>
                                    <%--<input type="text" readonly="readonly" value="${dep.departmentName }">--%>
                                    <%--<input type="hidden" name="packageDepartid" id="packageDepartid" value="${dep.departmentId }">--%>
                                    <%--</c:if>--%>
                                    <%--</c:forEach>--%>
                                    <%--</c:if>--%>


                                    <select name="packageDepartid" id="packageDepartid" onchange="hidediv()">
                                        <option value="">请选择</option>
                                        <c:if test="${depList != null}">
                                            <c:forEach items="${depList}" var="dep">
                                                <option value="${dep.departmentId}"
                                                        <c:if test="${muban.packageDepartid==dep.departmentId}">selected='true'</c:if> >${dep.departmentName}</option>
                                            </c:forEach>
                                        </c:if>
                                    </select>
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>外包装类型：</label>
                                <div class="kv-item-content">
                                    <select name="packageDaobaoId" id="packageDaobaoId">
                                        <option value="">请选择</option>
                                        <c:if test="${daolist != null}">
                                            <c:forEach items="${daolist}" var="dao">
                                                <option value="${dao.dabaoId}"
                                                        <c:if test="${dao.dabaoId==muban.packageDaobaoId}">selected</c:if>>${dao.dabaoName}</option>
                                            </c:forEach>
                                        </c:if>
                                    </select>
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>灭菌方式 ：</label>
                                <div class="kv-item-content">
                                    <select name="packageMiejunFangshi" id="packageMiejunFangshi">
                                        <option value="">请选择</option>
                                        <c:if test="${miejunFangshi != null}">
                                            <c:forEach items="${miejunFangshi}" var="miejunfangshi">
                                                <option value="${miejunfangshi.dictId}"
                                                        <c:if test="${miejunfangshi.dictId==muban.packageMiejunFangshi}">selected</c:if>>${miejunfangshi.dictName}</option>
                                            </c:forEach>
                                        </c:if>
                                    </select>
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>审核类型：</label>
                                <div class="kv-item-content">
                                    <select name="packageMiejunNo" id="packageMiejunNo">
                                        <option value="1" <c:if test="${muban.packageMiejunNo==1}">selected</c:if>>
                                            化学监测审核
                                        </option>
                                        <option value="2" <c:if test="${muban.packageMiejunNo==2}">selected</c:if>>
                                            化学监测审核+生物监测审核
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div class="kv-item clearfix">
                                <label ><span class="impInfo">*</span>是否打印条码 ：</label>
                                <div class="kv-item-content">
                                    <select name="packagePrint" id="packagePrint">
                                        <option value="">请选择</option>
                                        <option value="0" <c:if test="${muban.packagePrint==0}">selected</c:if>>不打印
                                        </option>
                                        <option value="1" <c:if test="${muban.packagePrint==1}">selected</c:if>>打印
                                        </option>
                                    </select>
                                </div>
                            </div>
                            <div >
                                <%--<c:if test="${muban.packageCategory != null }"></c:if>--%>
                                    <div class="kv-item clearfix" id="1">
                                        <label ><span class="impInfo">*</span>包属性 ：</label>
                                        <div class="kv-item-content">
                                            <select name="packageCategory" id="packageCategory">
                                                <option value="">请选择</option>
                                                <option value="0"
                                                        <c:if test="${muban.packageCategory==0}">selected</c:if>>单封
                                                </option>
                                                <option value="1"
                                                        <c:if test="${muban.packageCategory==1}">selected</c:if>>通用
                                                </option>
                                            </select>
                                        </div>
                                    </div>
                            </div>

                            <div class="kv-item clearfix">
                                <label >是否打印科室 ：</label>
                                <div class="kv-item-content">
                                    <select name="packageUseno" id="packageUseno">
                                        <option value="">请选择</option>
                                        <option value="1" <c:if test="${muban.packageUseno==1}">selected</c:if> >不打印</option>
                                        <option value="0" <c:if test="${muban.packageUseno==0}">selected</c:if> >打印</option>
                                    </select>
                                </div>
                            </div>

                            <div class="kv-item clearfix">
                                <label >是否配包录入 ：</label>
                                <div class="kv-item-content">
                                    <select name="packageType" id="packageType">
                                        <option value="">请选择</option>
                                        <option value="0" <c:if test="${muban.packageType==0}">selected</c:if> >不录入</option>
                                        <option value="1" <c:if test="${muban.packageType==1}">selected</c:if> >录入</option>
                                    </select>
                                </div>
                            </div>

                            <%--<div id="bbb" style="display: none;">--%>
                                   <%--<div class="kv-item clearfix" id="needhide">--%>
                                        <%--<label id="mc"><span class="impInfo">*</span>包属性 ：</label>--%>
                                        <%--<div class="kv-item-content">--%>
                                            <%--<select name="packageCategory" >--%>
                                                    <%--<option value="" >请选择</option>--%>
                                                    <%--<option value="0">通用</option>--%>
                                                    <%--<option value="1">单封</option>--%>
                                            <%--</select>--%>
                                        <%--</div>--%>
                                    <%--</div>--%>
                            <%--</div>--%>
                            <div class="kv-item clearfix">
                                <label><span class="impInfo"></span>备注：</label>
                                <div class="kv-item-content">
                                    <input type="text" placeholder="备注" name="packageText" value="${muban.packageText}">
                                </div>
                            </div>
                        </div>
                        <input type="hidden" name="packageId" value="${muban.packageId}">
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div id="saper-ft">
        <div class="buttons">
            <a href="javascript:;" class="sapar-btn sapar-btn-recom" id="savePackage">确认保存</a>
        </div>
    </div>
</div>
<script type="text/javascript">

    $(function () {
        $("#savePackage").click(function () {
            var btn = true;
            var baoming = $("#baoming").val();
            var packageDepartid = $("#packageDepartid").val();
            var packageDaobaoId = $("#packageDaobaoId").val();
            var packageMiejunFangshi = $("#packageMiejunFangshi").val();
            var packagePrint = $("#packagePrint").val();
            var packageCategory = $("#packageCategory").val();
            if (isNullOrEmpty(baoming)) {
                alert("请输入包名");
                btn = false;
                return btn;
            }
            if (isNullOrEmpty(packageDepartid)) {
                alert("请选择所属科室");
                btn = false;
                return btn;
            }
            if (isNullOrEmpty(packageDaobaoId)) {
                alert("请选择外包装类型");
                btn = false;
                return btn;
            }
            if (isNullOrEmpty(packageMiejunFangshi)) {
                alert("请选择包灭菌方式");
                btn = false;
                return btn;
            }
            if (isNullOrEmpty(packagePrint)) {
                alert("是否打印条码");
                btn = false;
                return btn;
            }
//            if ($("#needhide").is(":hidden")) {
//                packageCategory = '';
//            } else {
//                if (isNullOrEmpty(packageCategory)) {
//                    alert("请选择包属性");
//                    btn = false;
//                    return btn;
//                }
//            }
            $(".shushu").each(function () {
                if ($(this).val() == '') {
                    btn = false;
                    layer.msg("数量不能为空");
                    return false;
                }
            });
            if (btn) {
                showMask();
                debugger
                $.ajax({
                    type: "POST",
                    url: "${ctx}/shoushumuban/packageSingleSave.do",
                    data: $('#dataForm').serialize(),// 你的formid
                    error: function (request) {
                        layer.alert("网络故障，请稍后再试!");
                    },
                    success: function (data) {
                        $("#mask").hide();
                        if (data.status == "true") {
                            layer.alert("保存成功", function () {
                                window.location.href = "${ctx}/shoushumuban/ssmubanList.do";
                            });
                        } else {
                            layer.msg(data.msg);
                        }
                    }
                });
            }
        });
    })
    function hidediv() {
//	$("#aaa").remove();
//	$("#bbb").show();
//    var selvalue=$("#packageDepartid").val();
//    if(selvalue==15){
//    	$("#needhide").hide();
//    	packageCategory='';
//    }else{
//    	$("#needhide").show();
//    }
    }
    function isNullOrEmpty(strVal) {

        if (strVal == '' || strVal == null || strVal == undefined) {
            return true;
        } else {
            return false;
        }
    }
</script>
</body>
</html>